﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using OgilvyOne.IDAL;
using OgilvyOne.Model;
using OgilvyOne.DALFactory;

namespace OgilvyOne.BLL
{
    public partial class QuestionsManageBll
    {
        private readonly IQuestionsManage dal = QuestionsManageFactory.create();
        public QuestionsManageBll()
        { }
        #region  Method
        /// <summary>
        /// 是否存在该记录
        /// </summary>
        public bool Exists(int FAQ_ID)
        {
            return dal.Exists(FAQ_ID);
        }

        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(QuestionsManageModel model)
        {
            return dal.Add(model);
        }

        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(QuestionsManageModel model)
        {
            return dal.Update(model);
        }

        /// <summary>
        /// 删除一条数据
        /// </summary>
        public bool Delete(int FAQ_ID)
        {

            return dal.Delete(FAQ_ID);
        }
        /// <summary>
        /// 删除一条数据
        /// </summary>
        public bool DeleteList(string FAQ_IDlist)
        {
            return dal.DeleteList(FAQ_IDlist);
        }

        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public QuestionsManageModel GetModel(int FAQ_ID)
        {

            return dal.GetModel(FAQ_ID);
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetList(string strWhere)
        {
            return dal.GetList(strWhere);
        }
        /// <summary>
        /// 获得前几行数据
        /// </summary>
        public DataSet GetList(int Top, string strWhere, string filedOrder)
        {
            return dal.GetList(Top, strWhere, filedOrder);
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetAllList()
        {
            return GetList("");
        }

        /// <summary>
        /// 分页获取数据列表
        /// </summary>
        public List<QuestionsManageModel> GetPagedQuestions(int pageIndex, int pageSize,out int pageCount, out int rowCount)
        {           
            rowCount = -1;
            List<QuestionsManageModel> list = dal.GetPagedQuestions(pageIndex, pageSize, out rowCount);
            //计算出总页数
            pageCount = (int)Math.Ceiling(Convert.ToDouble(rowCount) / pageSize);//2            
            return list;
        }

        #endregion  Method
    }
}
